A content addressable memory (CAM), such as a ternary CAM (TCAM), can provide fast searching capabilities. For example, in a network communication application, a network device may use a TCAM module to store a plurality of switching rules. The plurality of switching rules can be used to determine an action on an incoming packet based on attributes of the incoming packet. Each switching rule can be stored in one or more TCAM entry lines in the TCAM module. A TCAM entry line may refer to a line of memory cells corresponding to a “word” address. During operation, all the TCAM entry lines can be compared with attributes of an incoming packet simultaneously to find a matching entry line belonging to a switching rule. The matching entry line can be used to inform the network device to handle the incoming packet according to the switching rule.
Generally, CAM entry lines of a CAM module can be configured according to a priority sequence. During a searching operation, it is possible that attributes of an incoming packet can match more than one CAM entry lines. The priority sequence can be used to select a CAM entry line that can be ahead of the rest of the more than one CAM entry lines according to the priority sequence. However, the priority sequence may be disturbed when entry lines are placed out of order in the CAM, as may occur if a redundant entry line is used to substitute a defective entry line conventionally.